FIND_PACKAGE (Lua)

ADD_CUSTOM_COMMAND (
    OUTPUT solv_lua.c
    COMMAND ${SWIG_EXECUTABLE} ${SWIG_FLAGS} -lua -I${CMAKE_SOURCE_DIR}/src -o solv_lua.c ${CMAKE_SOURCE_DIR}/bindings/solv.i
    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
    DEPENDS ${CMAKE_SOURCE_DIR}/bindings/solv.i
)

INCLUDE_DIRECTORIES (${LUA_INCLUDE_DIR})
IF (NOT LUA_INSTALL_DIR)
  SET(LUA_INSTALL_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/lua/${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR})
ENDIF (NOT LUA_INSTALL_DIR)

MESSAGE (STATUS "Lua installation dir: ${LUA_INSTALL_DIR}")

ADD_LIBRARY (bindings_lua SHARED solv_lua.c)
SET_TARGET_PROPERTIES (bindings_lua PROPERTIES PREFIX "" OUTPUT_NAME "solv" INSTALL_NAME_DIR "${LUA_INSTALL_DIR}")
TARGET_LINK_LIBRARIES (bindings_lua libsolvext libsolv ${LUA_LIBRARY} ${SYSTEM_LIBRARIES})
INSTALL (TARGETS bindings_lua LIBRARY DESTINATION ${LUA_INSTALL_DIR})

